<template>
	<view class="content">
		<!--  自定义导航栏 -->
		<NavBack></NavBack>
		<!--  播放器 -->
		<view 
				class="video-player"
				:style="'background-image: url('+ movie.backImage +'); background-repeat: no-repeat;background-size: 100% 230px;'"
				>
				
			<text class="player-icon text-white cuIcon-playfill" @tap="goSplayer"></text>
		</view>
		<!--  影片详情 -->
		<view class="video-content">
			<view class="video-title">
				<view class="video-name">
					 {{movie.sucai_miaosu}}
				</view>
				<view class="video-sd">
					 简介
				</view>
				<text class="video-more text-gray" :class="showDesc?'cuIcon-fold':'cuIcon-unfold'" @tap="ifShowDesc"></text>
			</view>
			<view class="video-desc">
				<view class="actors">
					 可修改范围:{{movie.fangwei}}
				</view>
			</view>
			<view class="video-desc">
				<view class="actors">
					 文件大小:{{movie.size}}
				</view>
			</view>
			<view class="video-desc">
				<view class="actors">
					 购买所需金额:{{movie.qian}}
				</view>
			</view>
		</view>
		<!--  选项 -->
		<view class="video-opt">
			<view class="opt bg-gradual-blue">
				<text class="opt-icon text-white cuIcon-down"></text>
				<view class="opt-name" @tap="down">
					下载
				</view>
				<view class="opt-name" @tap="down">
					收藏
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	import NavBack from '../../components/NavBack/index.vue';
	export default {
		components:{
			NavBack,
		},

		async onLoad(e){
			this.$httpApi.insert("Sp_material",this.caozuo
				)
			let data = await this.$httpApi.query({
				"Sp_material": {
					id: e.id
				}
			});
			let userInfo = this.$store.state.user;
			this.movie = data.Sp_material;
			this.sucai_id = e.id;
		},

		data() {
			return {
				userInfo:{},
				showDesc: false,
				sucai_id: "",
				movie:{
					'id': 0,
					'title': '大约在冬季 2019',
					'src': 'https://cn2.3days.cc/1577875712879260.jpeg',
					'actors': '马思纯, 霍建华, 魏大勋, 张瑶, 林柏宏, 文淇, 侯佩岑, 齐秦',
					'desc': '　1991年齐秦狂飙演唱会上，北师大才女安然（马思纯 饰）和来自台北的摄影师齐啸（霍建华 饰）因缘相识，曲终人散后再度重逢的二人陷入热恋，然而不是勇敢就一定能拥有爱，不是所有再见都能再见！在漂泊岁月中，弄丢了挚爱的我们，是否还能安然无恙？没有我的日子里，你是否能保重自己？2019年，齐啸和安然能否重逢？',
					'url': 'https://jx.7639616.com/?url=https://cn7.kankia.com/hls/20200101/5c361debcd70cbd3cd118bc9d24186a4/1577874894/index.m3u8'
				},
				caozuo:{
					user_id:this.$store.state.user.id,
					sucai_id:this.sucai_id,
					status:1
				}
			}
		},
		methods: {
			ifShowDesc(){
				this.showDesc = !this.showDesc;
			},
			goSplayer(){
				uni.setStorageSync('video-name',this.movie.urlJson[0].upload_percent);
				uni.navigateTo({
					url: "../Splayer/Splayer"
				})
			},
			async down(){
				for (var i = 0; i < this.movie.urlJson.length; i++) {
					let url = this.movie.urlJson[i];
					await this.downloadFile(url.upload_percent,`正在下载第${i+1}个视频`,res => {
						let show = `文件下载存放的路径是${res.tempFilePath}`;
						uni.showToast({
							title: show
						})
						console.log(show);
					})
				}
			}
		}
	}
</script>

<style>
	@import url('./index.css');
</style>
